package com.bbtShop.api;

import com.bbtShop.aop.Login;
import com.bbtShop.core.model.*;
import com.bbtShop.service.PaySourceService;
import com.bbtShop.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author manke
 * @Date 2020/10/22 11:39
 * @Version 0.0.1
 */
@Api(value = "PaySourceController", description = "收入支出控制器")
@RestController
@RequestMapping("/PaySource")
public class PaySourceController {

    @Autowired
    private PaySourceService paySourceService;

    @ApiOperation(value = "getPayList", notes = "获取产品列表")
    @PostMapping("/getPayList")
    @Login(permission = "PaySource:getPayList")
    public ApiResponse<Object> getPayList(@RequestParam(required = false) Integer pageNum,
                                             @RequestParam(required = false) Integer pageSize,
                                             @RequestBody PaySource paySource){
        return ApiResponse.success(paySourceService.getPayList(pageNum,pageSize, paySource));
    }

    @ApiOperation(value = "addUpdatePay", notes = "添加修改产品")
    @PostMapping("/addUpdatePay")
    @Login(permission = "PaySource:addUpdatePay")
    public ApiResponse<Object> addUpdatePay(@RequestBody PaySource paySource){
        paySourceService.addUpdatePay(paySource);
        return ApiResponse.success();
    }

    @ApiOperation(value = "delPay", notes = "删除产品")
    @PostMapping("/delPay")
    @Login(permission = "PaySource:addUpdatePay")
    public ApiResponse<Object> delPay(@RequestBody Ids ids){
        paySourceService.delPay(ids);
        return ApiResponse.success();
    }

    @ApiOperation(value = "getPayInfo", notes = "获取产品详情信息")
    @GetMapping("/getPayInfo")
    @Login(permission = "PaySource:addUpdatePay")
    public ApiResponse<PaySource> getPayInfo(@RequestParam Integer id){
        return ApiResponse.success(paySourceService.getPayInfo(id));
    }
}
